package io.renren.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.dao.TemporaryOrderDao;
import io.renren.dto.TemporaryOrderDTO;
import io.renren.entity.TemporaryOrderEntity;
import io.renren.entity.UserEntity;
import io.renren.service.TemporaryOrderService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 临时采购表
 *
 * @author 翟文闯 619556390@QQ.com
 * @since 1.0.0 2019-12-31
 */
@Service
public class TemporaryOrderServiceImpl extends CrudServiceImpl<TemporaryOrderDao, TemporaryOrderEntity, TemporaryOrderDTO> implements TemporaryOrderService {

    @Autowired
    private TemporaryOrderDao temporaryOrderDao;
    @Override
    public QueryWrapper<TemporaryOrderEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<TemporaryOrderEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public TemporaryOrderDTO getTemOrder(int sign,Long chedId, Long canteenId) {
        TemporaryOrderDTO dto = temporaryOrderDao.getTemOrder(sign,chedId, canteenId);
        return dto;
    }



    /**
     * 根据id删除所有的数据
     * @param sign
     * @param canteenId
     */
    @Override
    public void deleteOrder(int sign ,long canteenId) {
       temporaryOrderDao.deleteOrder(sign,canteenId);
    }
}